
package cz.uhk.ppro.response.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

/**
 * @author Martin Zmítko <martin.zmitko@gmail.com>
 */
@Entity
@Table(name="COURSE")
public class Course extends NamedEntity implements Serializable {

    @ManyToOne(fetch=FetchType.EAGER)
    private Teacher teacher;

    @ManyToMany(fetch=FetchType.EAGER, cascade= CascadeType.REFRESH)
    private List<Student> students;

    @ManyToMany(cascade= CascadeType.REFRESH)
    private List<Test> tests;

    public Teacher getTeacher()
    {
        return this.teacher;
    }

    public List<Student> getStudents()
    {
        return students;
    }

    public List<Test> getTests()
    {
        if(tests == null) {
            tests = new ArrayList<>();
        }
        return tests;
    }

    public void setTeacher (Teacher teacher)
    {
        this.teacher = teacher;
    }

    public void setStudents(List<Student> students)
    {
        this.students = students;
    }

     public void setTests(List<Test> tests)
    {
        this.tests = tests;
    }

}
